<template>
    <div class="safework">
        <div class="content">
            <div class="c-top">
                <div class="c-list">
                    <div class="c-left">
                        项目名称
                    </div>
                    <div class="c-right">
                        <!-- {{dataList.ProjectName}} -->
                        {{userInfo.departsir == 2?userInfo.pdeptname:dataList.ProjectName}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        申请单位
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.DeptName}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        申请拆除日期
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.StartDate?dataList.StartDate.substring(0,10):''}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        拟定拆除部位
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.Area|changeposition}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        拆除防护设施类型
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.TypeText}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        拆除原因
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.ReasonText}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        临时采取安全防护措施
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        {{dataList.ProtectionText}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        计划恢复(完工)时间
                        <i class="iconfont icon-required"></i>
                    </div>
                    <div class="c-right">
                        <!--<div class="c-select">请选择</div>
                     <img src="../../../../static/images/5.png"  @click="showmsg" >-->
                        {{dataList.EndDate}}
                    </div>
                </div>
                <div class="c-list">
                    <div class="c-left">
                        申请人
                    </div>
                    <div class="c-right">
                        {{dataList.PersonName}}
                    </div>
                </div>
            </div>
            <div class="line"></div>
            <div class="approveTit">审批信息</div>
            <div v-for="(item,index) in dataList.ApproveInfo"
                 :key="index"
                 class="list-item">
                <div class="content-show">
                    <div class="c-l-l">
                        <div>审批意见</div>
                        <!-- <textarea maxlength="1000"
                                  v-model="item.Remark"
                                  disabled
                                  class="textarea"></textarea> -->
                        <p class="textarea">{{item.Remark}}</p>
                    </div>
                </div>
                <div class="content-show">
                    <div class="c-l-ll">
                        <div class="tofirst">
                            审批结论
                        </div>
                        <div class="rightselct">
                            <span>{{item.ApproveResult}}</span>
                        </div>
                    </div>
                </div>
                <div class="form-item form-item-style1">
                    <div class="label-title">
                        <label>审批人</label>
                    </div>
                    <div>
                        <p>{{item.ApprovePersonName}}</p>
                    </div>
                </div>
                <div class="line"></div>
            </div>
            <div class="content-show"
                 v-if="syself">
                <div class="c-l-l">
                    <div>审批意见</div>
                    <textarea maxlength="1000"
                              v-model="ApproveRemark"
                              placeholder="请输入意见（自行换行）"
                              class="textarea"></textarea>
                </div>
            </div>
            <div class="content-show"
                 v-if="syself">
                <div class="c-l-ll">
                    <div class="tofirst">
                        审批结论
                    </div>
                    <div class="rightselct">
                        <div class="tofirst"
                             @click="showclick(1)">
                            <div class="selecti"
                                 :class="showmark==1?'active':''"></div>
                            <div>通过</div>
                        </div>
                        <div class="tofirst"
                             @click="showclick(2)">
                            <div class="selecti"
                                 :class="showmark==2?'active':''"></div>
                            <div>不通过</div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="form-item form-item-style1"
                 v-if="syself">
                <div class="label-title">
                    <label>审批人</label>
                </div>
                <div>
                    <p>{{userInfo.username}}</p>
                </div>
            </div>
            <div class="c-btn"
                 v-if="syself">
                <div class="c-submit"
                     @click="submitmessage">提交</div>

            </div>
        </div>
        <myMenu></myMenu>
    </div>
</template>

<script>

import myMenu from '@/commonComponents/menu'
export default {
    name: 'App',
    directives: {
        // TransferDom
    },
    data () {
        return {
            options1: ['A单位'],
            options2: ['安全类'],
            active: 1,
            showflag: false,
            userId: '',
            tokenId: '',
            projectId: '',
            userInfo: '',
            dataList: {
                id: '', //	String	否	拆除申请ID（修改时存在，新增时为空）
                projectName: '', //	String	否	项目名称
                projectId: '', //	String	否	项目ID
                deptName: '', //	String	否	申请单位名称
                deptId: '', //	String	否	申请单位ID
                startDate: '', //	String	否	申请拆除日期
                endDate: '', //	String	否	计划完工时间
                area: '', //	String	否	拟定拆除部位，格式化输入，每个输入区域用“◇”分隔（__区__#楼__层__轴）
                typeText: '', //	String	否	拆除防护设施类型（多选，","分隔）
                reasonText: '', //	String	否	拆除原因（多选，“,”分隔）
                protectionText: '', //	String	否	临时安全防护措施（可多选，","分隔）
                personId: '', //	String	否	申请人ID
                personName: '' //	String	否	申请人名称
            },
            checkResult: true,
            ApproveRemark: '',
            showmark: 1,
            syself: '',
            addflag: true
        }
    },
    components: {
        myMenu
    },
    computed: {
    },
    watch: {
    },
    created () {
        this.userInfo = JSON.parse(localStorage.userInfo)
        this.userId = this.userInfo.userid
        this.tokenId = this.userInfo.tokenId
        this.projectId = this.userInfo.deptid
        // this.syself = this.rolecheck()
        this.getDate()
    },
    methods: {
        rolecheck () {
            // index==1  验证是否是项目施工员  index==2  验证是否是设备管理员
            let arr = []
            let flag = false
            arr = this.userInfo.usermode.split(',')
            arr.forEach(
                (item, index) => {
                    if (item == '项目生产经理') {
                        flag = true
                    }
                }
            )
            return flag
        },
        getDate () {
            let param = {
                'allowPaging': true,
                'business': 'GetDismantleJob',
                'data': {
                    'id': this.$route.query.id
                },
                'pageIndex': 0,
                'pageSize': 20,
                'tokenId': this.tokenId,
                'userId': this.userId
            }
            this.$axiosAjax.getConfigJson(
                param
            ).then(
                (res) => {
                    this.dataList = res.data.data
                    this.syself = res.data.data.CanEdit
                    // this.subProjectsList = res.data.data.SubProjects;
                    // this.changemove();
                }
            )
        },
        submitmessage () {
            if (!this.addflag) {
                return false
            }
            this.addflag = false
            let param = {
                'allowPaging': true,
                'business': 'DismantleCheck',
                'data': {
                    id: this.$route.query.id, // String		起重吊装作业ID
                    checkResult: this.checkResult,	// boolean		是否通过审核
                    ApproveRemark: this.ApproveRemark, // String		审批人意见
                    stateType: 2
                },
                'pageIndex': 0,
                'pageSize': 20,
                'tokenId': this.tokenId,
                'userId': this.userId
            }
            this.$vux.loading.show({
                text: '正在提交中...'
            })
            this.$axiosAjax.getConfigJson(
                param
            ).then(
                (res) => {
                    if (res.data.code == 0) {
                        // this.$router.push('/workrisk')
                        this.$router.go(-1)
                    } else {
                        this.addflag = true
                    }
                }
            ).catch(
                () => {
                    this.addflag = true
                }
            )
        },
        showclick (index) {
            if (index == 1) {
                this.showmark = 1
                this.checkResult = true
            } else {
                this.showmark = 2
                this.checkResult = false
            }
        }
    },
    filters: {
        changeposition (val) {
            if (!val) {
                return false
            }
            let arr = []
            arr = val.split('◇')
            return `${arr[0]}区${arr[1]}楼${arr[2]}层${arr[3]}轴`
        }
    }
}
</script>

<style scoped lang="less">
.safework {
    background-color: #ebeef3;
    height: 100%;
}
.content {
    background-color: #fff;
}
.c-top {
    background-color: #fff;
    padding-left: 20px;
}
.c-list {
    padding: 20px 20px 20px 0;
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #efeff4;
}
.c-left {
    color: #333333;
    font-size: 14px;
    position: relative;
}
.c-left > i {
    position: absolute;
    top: -5px;
    right: -18px;
}
.c-right {
    color: #999;
    font-size: 14px;
    // display:flex;
    align-items: center;
    width: 160px;
    text-align: right;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}
.c-select {
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
    // width:200px;
    margin-right: 6px;
    text-align: right;
}
.c-btn {
    height: 113px;
    padding-top: 32px;
}
.c-submit {
    width: 200px;
    height: 40px;
    line-height: 40px;
    text-align: center;
    font-size: 15px;
    color: #fff;
    border-radius: 20px;
    background-color: #2269ff;
    margin: 0 auto;
}
.content-show {
    padding-left: 20px;
    background-color: #fff;
}
.c-l-l {
    height: 95px;
    padding-top: 28px;
    padding-right: 20px;
    border-bottom: 1px solid #ebeef3;
}
.c-l-l > div {
    font-size: 14px;
    color: #333;
}
.textarea {
    color: #999;
    font-size: 14px;
    background: #fff;
}
.approveTit {
    height: 55px;
    line-height: 55px;
    margin-left: 20px;
    font-size: 15px;
    color: #2269ff;
    border-bottom: 1px solid #efeff4;
}
.textarea {
    width: 100%;
    border: 0;
    outline: none;
    margin-top: 10px;
}
.newMsg {
    margin-top: 20px;
    padding-right: 20px;
    color: #999;
}
.c-l-ll {
    display: flex;
    justify-content: space-between;
    border-bottom: 1px solid #ebeef3;
}
.rightselct {
    display: flex;
    align-items: center;
}
.rightselct span {
    color: #999;
    font-size: 14px;
    padding-right: 20px;
}
.tofirst {
    display: flex;
    align-items: center;
    width: 120px;
    height: 55px;
    text-align: center;
    font-size: 14px;
    color: #333;
}
.selecti {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #999;
    margin-right: 10px;
}
.selecti.active {
    border: 3px solid #226afd;
}
.line {
    border-bottom: 10px solid #ebeef2;
}
</style>
